# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=seed7
pkgver=05.20240322
pkgrel=0
_pkgver="${pkgver//./_}"
pkgdesc="High-level, extensible programming language"
url="https://seed7.sourceforge.net/"
# armhf, armv7: rand tests from chkflt fail
arch="all !armhf !armv7"
license="GPL-2.0-or-later AND LGPL-2.1-or-later"
makedepends="
	freetds-dev
	libx11-dev
	libxrender-dev
	mariadb-connector-c-dev
	ncurses-dev
	postgresql-dev
	sqlite-dev
	unixodbc-dev
	"
subpackages="
	$pkgname-doc
	$pkgname-nano::noarch
	$pkgname-vim::noarch
	"
source="https://downloads.sourceforge.net/seed7/seed7_$_pkgver.tgz
	makefile.patch
	"
builddir="$srcdir/seed7/src"

_s7include=/usr/lib/seed7/lib
_s7runtime=/usr/lib/seed7/bin

prepare() {
	default_prepare

	make depend \
		SEED7_LIBRARY=$_s7include \
		S7_LIB_DIR=$_s7runtime
}

build() {
	make all
	make make7
}

check() {
	make test
}

package() {
	cd "$srcdir/seed7"

	# install interpreter, compiler, and make
	install -Dvm755 bin/s7 bin/s7c bin/make7 -t "$pkgdir"/usr/bin/

	# install Seed7 library
	install -Dvm644 lib/*.s7i -t "$pkgdir"$_s7include/
	install -Dvm644 lib/comp/*.s7i -t "$pkgdir"$_s7include/comp/

	# install static libraries
	install -Dvm644 bin/*.a -t "$pkgdir"$_s7runtime/

	# install vim and nano syntax files
	install -Dvm644 doc/sd7.vim -t "$pkgdir"/usr/share/vim/vimfiles/ftdetect/
	install -Dvm644 doc/seed7.vim -t "$pkgdir"/usr/share/vim/vimfiles/syntax/
	install -Dvm644 doc/seed7.nanorc -t "$pkgdir"/usr/share/nano/

	# install docs, man pages, and examples
	install -Dvm644 doc/*.txt -t "$pkgdir"/usr/share/doc/$pkgname/
	install -Dvm644 doc/*.1 -t "$pkgdir"/usr/share/man/man1/
	install -Dvm644 prg/*.dna prg/*.sd7 prg/*.dat prg/*.s7i \
		-t "$pkgdir"/usr/share/doc/$pkgname/examples/
}

nano() {
	pkgdesc="$pkgdesc (nano syntax)"
	install_if="$pkgname=$pkgver-r$pkgrel nano"
	depends=

	amove usr/share/nano
}

vim() {
	pkgdesc="$pkgdesc (vim syntax)"
	install_if="$pkgname=$pkgver-r$pkgrel vim"
	depends=

	amove usr/share/vim/vimfiles
}

sha512sums="
5e0436696e76376e7e0752c3dd3861422267804955bd300f3377476d3870abd726f131bce55bdee84102f19b090ff349015a6ddd7e4c2732372dac084cead9c6  seed7_05_20240322.tgz
1028e81c04cca92929f48f6bdcf93ea109d4ba423b4b6183980758b606707388497ebdd828fe22cc7d69f94abaecace77ca7337fca7644c71018a8c0ec4fdb3f  makefile.patch
"
